package com.ecjtu.stadiumre_servations.entity.domain;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.ecjtu.stadiumre_servations.entity.dto.DataAnalysisDTO.DataDetailedDTO;
import lombok.Data;

import java.io.Serializable;
import java.time.LocalDate;

/**
 * 使用分析：场地实际使用时间段（排除取消预约），返回map<场馆ID，使用时间段>
 * 服务偏好分析：场地实际使用（排除取消预约），统计数量，返回map<场馆ID，使用次数>
 * 场地使用效率：场地的实际使用时长（排除取消预约），统计时长，返回map<场馆ID，使用时长>
 * 收入分析：个人预约和团队预约占比及利润，返回Double两种利润及占比
 */

@TableName("data_analysis")
@Data
public class DataAnalysis implements Serializable {
    /**
     * ID
     */
    @TableId(value = "data_id" ,type = IdType.INPUT)
    private int id;
    /**
     * 场馆ID
     */
    private String venueId;
    /**
     * 场馆类型
     */
    private String venueType;
    /**
     * 场地实际使用时间段
     */
    @TableField("period")
    private String period;
    /**
     * 个人预约和团队预约的  时长
     */
    private Long singleTime;
    private Long groupTime;
    private Long totalTime;
    /**
     * 时长占比
     */
    private Double singleTimeRatio;
    private Double groupTimeRatio;
    /**
     * 利润
     */
    private Double singleProfit;
    private Double groupProfit;
    private Double totalProfit;
    /**
     * 利润占比
     */
    private Double singleProfitRatio;
    private Double groupProfitRatio;
    /**
     * 预约次数
     */
    private Integer singleCount;
    private Integer groupCount;
    private Integer totalCount;
    /**
     * 预约次数占比
     */
    private Double singleCountRatio;
    private Double groupCountRatio;
    /**
     * 统计的时间，一天一次
     */
    private LocalDate statTime;

    public DataAnalysis(String venueId, DataDetailedDTO dataDetailedDTO, LocalDate statTime) {
        this.venueId = venueId;
        this.period = dataDetailedDTO.getPeriod();
        this.venueType = dataDetailedDTO.getVenueType();

        this.singleTime = dataDetailedDTO.getSingleTime();
        this.groupTime = dataDetailedDTO.getGroupTime();
        this.totalTime = dataDetailedDTO.getTotalTime();

        this.singleTimeRatio = dataDetailedDTO.getSingleTimeRatio();
        this.groupTimeRatio = dataDetailedDTO.getGroupTimeRatio();

        this.singleProfit = dataDetailedDTO.getSingleProfit();
        this.groupProfit = dataDetailedDTO.getGroupProfit();
        this.totalProfit = dataDetailedDTO.getTotalProfit();

        this.singleProfitRatio = dataDetailedDTO.getSingleProfitRatio();
        this.groupProfitRatio = dataDetailedDTO.getGroupProfitRatio();

        this.singleCount = dataDetailedDTO.getSingleCount();
        this.groupCount = dataDetailedDTO.getGroupCount();
        this.totalCount = dataDetailedDTO.getTotalCount();

        this.singleCountRatio = dataDetailedDTO.getSingleCountRatio();
        this.groupCountRatio = dataDetailedDTO.getGroupCountRatio();

        this.statTime = statTime;
    }

    public DataAnalysis() {
    }
}
